<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>宝贝投-P2P平台</title>
<link rel="shortcut icon" href="favicon.ico" />
<link rel="stylesheet" href="js/bootstrap-3.3.2-dist/css/bootstrap.css" type="text/css" />
<link rel="stylesheet" href="css/core.css" type="text/css" />
<script type="text/javascript" src="js/jquery/jquery-2.1.3.js"></script>
<script type="text/javascript" src="js/bootstrap-3.3.2-dist/js/bootstrap.js"></script>
<script type="text/javascript" src="js/jquery.bootstrap.js"></script>
<script type="text/javascript" src="js/plugins/jquery-validation/jquery.validate.js"></script>
<script type="text/javascript" src="js/plugins/jquery-validation/localization/messages_zh.js"></script>
<script type="text/javascript" src="js/plugins/jquery.form.js"></script>
<script type="text/javascript" src="js/common.js"></script>

<style type="text/css">
	.el-login-form{
		width:600px;
		height: 400px;
		margin-left:auto;
		margin-right:auto;
		margin-top: 20px;
	}

	.el-login-form .form-control{
		width: 220px;
		display: inline;
	}
</style>
</head>
<body>
	<!-- 网页头信息 -->
	<div class="el-header" >
		<div class="container" style="position: relative;">
			<ul class="nav navbar-nav navbar-right">
				<li><a href="index.html">首页</a></li>
				<li><a href="login.html">登录</a></li>
				<li><a href="#">帮助</a></li>
			</ul>
		</div>
	</div>
	
	<!-- 网页导航 --> 
	<div class="navbar navbar-default el-navbar">
		<div class="container">
			<div class="navbar-header">
				<span class="el-page-title">用户登录</span>
			</div>
		</div>
	</div>
	
	<!-- 网页内容 --> 
	<div class="container">  
		<form id="loginForm" class="form-horizontal el-login-form" action="http://localhost:8080/user/login" method="post" >
			<p class="h4" style="margin: 10px 10px 20px 110px;color:#999;">请输入用户名和密码</p> 
			<div class="form-group">
				<label class="control-label col-sm-2">用户名</label>
				<div class="col-sm-10">
					<input type="text" autocomplete="off" id="username" name="username" class="form-control" value=""/>
				</div> 
			</div>
			<div class="form-group">
				<label class="control-label col-sm-2">密&emsp;码</label>
				<div class="col-sm-10">
					<input type="password" autocomplete="off" id="password" name="password" class="form-control" value=""/>
				</div>
			</div>
			<div class="form-gorup">
				<div class="col-sm-offset-3">
				    <input type="hidden" name="accountType" value="1" />
					<button type="submit" class="btn btn-success" style="width: 100px;">
						登录
					</button>
					&emsp;&emsp;
					<a href="register.html">新用户，马上注册</a>
				</div>
			</div>
		</form>
	</div>
	<!-- 页脚 begin -->
	<div class="container-foot-2">
		<div class="context">
			<p>版权所有：2019长沙科泰信息技限公司&emsp;&emsp;&emsp;
				地址：长沙市开福区青竹湖街湘江北路一段369号1栋&emsp;&emsp;&emsp;
				ICP备案：湘ICP备10009111号
			</p>
			<div class="clearfix"></div>
		</div>
	</div>
	<!-- 页脚 end -->
</body>
<script type="text/javascript">

	// 需要跳转的网页路径
	let redirectUrl = GetQueryString('redirectUrl');

	$(function(){
		// '登录表单'验证
		$("#loginForm").validate({
			rules:{
				username: { required: true },
				password: { required: true }
			},
			messages: {
				username: { required:"&emsp;请输入用户名" },
				password: { required:"&emsp;请输入密码" }
			},
			errorClass:"text-danger",
			highlight:function(input){
				$(input).closest(".form-group").addClass("has-error");
			},
			unhighlight:function(input){
				$(input).closest(".form-group").removeClass("has-error");
			},
			submitHandler:function(form){

				$(form).ajaxSubmit(function(result){

					// 如果返回的数据的响应码不是'成功(200)'
					if(result.code != 200) {
						$.messager.alert(result.message);
						return;
					}
					// 如果返回的数据响应码为200
					// 将账户信息存入到客户端session中
					sessionStorage.setItem( "user", JSON.stringify(result.data) );

					$.messager.confirm("提示",'登录成功!',function(){
						// 如果请求路径中，存在需要跳转的URL，就跳转到指定URL中
						// 否则，跳转到首页
						if(redirectUrl)
							window.location.href= './' + redirectUrl;
						else
							window.location.href="index.html";

					});


				});// $(form).ajaxSubmit(function(result));

			}// submitHandler:function(form);
		});
	});

</script>
<ml>
</html>